feat: replace render-time text wrapping with browser-native wrapping#191
Conversation
|
@hyperfinitism is attempting to deploy a commit to the martin-mfg's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
martin-mfg
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Please ignore the failing "Backend E2E test" pipeline. It determined that this PR generates different output than the master branch, which is expected here.
Currently the changes in this PR lead to visual changes in generated cards regardless of line wrapping. Especially the line height is increased. Could you please ensure there are no visual changes apart from the line wrapping? Maybe it makes sense to simply copy the HTML code which GitHub itself uses in the original repo pins on user profiles?
Doing this would also raise the question if it makes sense to use foreignObject for the whole content of gist/pin cards. I.e. not only the description, but also the title, star count, etc. What do you think?
| : "" | ||
| } | ||
|
|
||
| <text class="description" x="${X_OFFSET}" y="-5"> |
There was a problem hiding this comment.
Does removing the "-5" here not change the layout of the final card?
There was a problem hiding this comment.
Strictly speaking it does; the new position depends on the browser's HTML/font metrics rather than the SVG baseline, so the first-line baseline can drift by about < 1px. In practice the visual top of the description lines up at the same place and the appearance is nearly identical.
f9af708 to
0c6113b
Compare
Use `foreignObject` with CSS line-clamp to let the browser handle text wrapping natively instead of manually wrapping on the server. This provides better font-aware wrapping while keeping server-side line estimation for SVG height calculation. Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
0c6113b to
7da1078
Compare
While this approach maintains the greatest visual consistency, it has the following problems:
|
I agree we should not further extend the usage of foreignObject here. I have made some changes based on your branch:
I have pushed them as a new branch. I tried pushing them directly to your fork, but it seems this GitHub bug prevent this. What I still want to do is to visually compare new card output to card output from master branch and make sure visual changes are mostly limited to line wrapping. Including on different operating systems and in different browsers. Then I'd like to merge this PR once we're about to release a new major version of github-stats-extended. But first, do you have any comments on my code changes? |
|
I think it is a good idea to allow users to switch between rendering modes. I have cherry-picked all of your commits from the branch. |
This PR uses
foreignObjectwith CSS line-clamp to let the browser handle text wrapping natively instead of manually wrapping on the server. This provides better font-aware wrapping while keeping server-side line estimation for SVG height calculation.Fixes anuraghazra#4862.
Example card